/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021.
 * Description: Save the kallsyms in symbuf and load
 *              them dynamically into the kernel.
 * Author: hanzongcheng
 * Create: 2021-06-15
 */
#include <linux/module.h>
#include <linux/rtos/extract_kallsyms.h>

static struct rtos_kallsyms_struct symbuf;

static int __init rtos_load_kallsyms(void)
{
	int ret = 0;

	symbuf.num_syms = (unsigned int *)&rtos_mod_kallsyms_num_syms;
	symbuf.offsets = rtos_mod_kallsyms_offsets;
	symbuf.names = rtos_mod_kallsyms_names;
	symbuf.token_table = rtos_mod_kallsyms_token_table;
	symbuf.token_index = rtos_mod_kallsyms_token_index;
	symbuf.markers = rtos_mod_kallsyms_markers;

	ret = rtos_kallsyms_init(&symbuf);
	if (ret)
		pr_info("rtos_kallsyms: Failed to loaded symbols!\n");
	else
		pr_info("rtos_kallsyms: Successfully loaded symbols!\n");

	return ret;
}

MODULE_LICENSE("GPL");
MODULE_IMPORT_NS(RTOS_EXTRACT_KALLSYMS);
module_init(rtos_load_kallsyms);
